package com.igeekhome.ccs.biz.impl;

import com.igeekhome.ccs.biz.IMessageBiz;
import com.igeekhome.ccs.entity.Message;
import com.igeekhome.ccs.entity.Session;
import com.igeekhome.ccs.mapper.MessageMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class MessageBizImpl implements IMessageBiz {
    @Autowired
    private MessageMapper mm;

    @Override
    public int sendMessage(int id, String content) {
        Message m = new Message();
        m.setSessionId(id);
        m.setContent(content);
        m.setMessageTime(new Date());
        mm.sendMessage(m);
        return 0;
    }

    @Override
    public int todayMessageNumber(int id) {
        return mm.todayMessageNumber(new Date());
    }

    @Override
    public List<Session> getSessionMessage(int sessionId) {

        return mm.getSessionMessage(sessionId);
    }
}
